<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

  <script src="jquery.js"></script>

  <style>
      #big{
        margin: auto 0;
        text-align: center;
        height: 2000px;
      }
  </style>

</head>
<body>
  <div id="big">
    <h2>核酸检测系统</h2>

    <form action="/getList" >
      <select name="hospitalId">
        <option value="0" >——请选择——</option>
        <option th:selected="${name.id == hospitalId}" th:each="name : ${hospitalName}" th:value="${name.id}" th:text="${name.name}"></option>
      </select>
      <input type="submit" value="查询">

    </form>
    <button onclick="addMedicalAssay()">添加</button>

    <table width="1200px"  border="1px">
      <tr>
        <th>监测人员</th>
        <th>被检测人手机号</th>
        <th>被检测人身份证号</th>
        <th>检测机构</th>
        <th>检测日期</th>
        <th>检测结果</th>
        <th>操作</th>
      </tr>
      <tr th:each="obj : ${data}">
        <td th:text="${obj.assayUser}"></td>
        <td th:text="${obj.phone}"></td>
        <td th:text="${obj.cardNum}"></td>
        <td th:text="${obj.hospitalName}"></td>
        <td th:text="${#dates.format(obj.assayTime,'yyyy-MM-dd')}"></td>
        <td th:text="${obj.assayResult == 0?'检验中':'确诊'}"></td>
        <td><a th:id="${obj.id}" href="javascript:void(0)" onclick="confirmation(this)">确诊</a></td>
      </tr>
    </table>

  </div>
</body>


<script>
  function addMedicalAssay() {
    location.href = "/toAdd"
  }

  function confirmation(obj){
    if(confirm("请确认该检测者是否确诊？")){
      $.ajax({
        url:"/confirmation/"+obj.id,
        type:'get',
        success:function (data){
          if(data){
            $(obj).parent().prev().text("确诊")
          }
        }
      })
    }
  }
</script>

</html>